package com.liuwei.msmall.cart.config;

import com.liuwei.msmall.cart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Classname MyMvcConfig
 * @Description TODO
 * @Date 2020/6/27 20:57
 * @Created by 刘
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer{
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {

        //默认进来访问购物车列表
        registry.addViewController("/").setViewName("cart");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册自定义拦截器,拦截本服务下的所有请求
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");

    }
}
